package homework.mid_autumn_festival.collection_exercixe;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo3 {
    public static void main(String[] args) {
        //集合仅能保存引用类型元素,并且保存的是元素的地址
        Collection c = new ArrayList();

        Person p = new Person(1, 2);
        c.add(p);//将p添加到集合c中-----将引用(地址)装到了c中
        System.out.println(p);//{1,2}
        System.out.println(c);//[{1,2}]

        p.setX(100);
        System.out.println(p);//{100,2}
        System.out.println(c);//[{100,2}]




    }
}
